package cn.jly.springboot24;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 基于spring boot 2.4.2版本
 *
 * @author lanyangji
 */
@EnableConfigurationProperties
@ImportResource(value = {"classpath:config/spring-beans.xml"}) // 导入spring配置文件
@RestController
@SpringBootApplication
public class Springboot24VersionApplication {

	public static void main(String[] args) {
		// ioc容器
		final ConfigurableApplicationContext context = SpringApplication.run(Springboot24VersionApplication.class, args);

		// 打印注册的组件
		Arrays.stream(context.getBeanDefinitionNames()).forEach(System.out::println);
	}

	@GetMapping("/hello")
	public String sayHello(String name) {
		return "hello, " + name;
	}
}
